var port = (process.env.VMC_APP_PORT || 3000);
var host = (process.env.VCAP_APP_HOST || 'localhost');
var fs = require('fs')
    , http = require('http')
    , socketio = require('socket.io');
 
var server = http.createServer(function(req, res) {
    res.writeHead(200, { 'Content-type': 'text/html'});
    res.end(fs.readFileSync(__dirname + '/index.html'));
}).listen(port, host);
 
socketio.listen(server).on('connection', function (socket) {
    socket.on('message', function (msg,user) {
        console.log('Message Received: ', msg,user);
        socket.broadcast.emit('message', msg,user);
    });
});

 
